﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ArticlesDetails.aspx.cs"
    Inherits="ArticlesDetails" %>

<%@ Register Src="UserControls/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="UserControls/MainNav.ascx" TagName="MainNav" TagPrefix="uc2" %>
<%@ Register Src="UserControls/SlideOto.ascx" TagName="SlideOto" TagPrefix="uc3" %>
<%@ Register Src="UserControls/LeftBar.ascx" TagName="LeftBar" TagPrefix="uc4" %>
<%@ Register Src="UserControls/RightBar.ascx" TagName="RightBar" TagPrefix="uc5" %>
<%@ Register Src="UserControls/Footer.ascx" TagName="Footer" TagPrefix="uc6" %>
<%@ Register Src="UserControls/Category.ascx" TagName="Category" TagPrefix="uc7" %>
<%@ Import Namespace="BLL" %>
<%@ Register src="UserControls/AddButton.ascx" tagname="AddButton" tagprefix="uc8" %>
<script runat="server">
    CategoryBLL cate = new CategoryBLL();
    ArticleBLL artic = new ArticleBLL();
    VideoBLL video = new VideoBLL();
    GalleryBLL gallery = new GalleryBLL();
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Trang chủ</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="/Styles/style.css" type="text/css" media="screen"
        charset="utf-8" />
    <link rel="stylesheet" href="/Styles/nivo-slider.css" type="text/css" />
    <link rel="stylesheet" href="/Styles/nivo-style.css" type="text/css" />
    <script type="text/javascript" charset="utf-8" src="/Scripts/dropdown.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.nivo.slider.pack.js"></script>
    <script type="text/javascript" src="/Scripts/jquery.jcarousel.min.js"></script>
    <!-- Gallery Viewer -->
    <link href="/Styles/jquery.galleryview-3.0-dev.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
    <script src="/Scripts/jquery.timers-1.2.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.easing.1.3.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.galleryview-3.0-dev.js" type="text/javascript"></script>
    <!-- End Gallery Viewer -->
    <script type="text/javascript" language="javascript" src="/Scripts/jquery.carouFredSel-2.1.3.js"></script>
    <script type="text/javascript">
            $(window).load(function() {
                $('.nivoSlider').nivoSlider({
                    effect: 'random',
                    slices:8,
                    animSpeed:900, 
                    pauseTime:3000,
                    startSlide:0, 
                    directionNav:false, 
                });
            });

            $(document).ready(function () {
              $(".now").click(function () {
                //var isEnbles = $('.now').text();
                var isEnbles = document.getElementsByClassName('now');
                $('#loading').html("<p>Vui lòng chờ <img src='/Images/loading.gif'/></p>").fadeIn('fast');
                alert(isEnbles);
                $.ajax({
                    type: "POST",
                    url: "/Home.aspx/LoadControl",
                    data: "{ type:"  + isEnbles + "}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (msg) {
                        //alert("thanhcong");
                        //alert(JSON.stringify(msg));
                        $('#loading').fadeOut('fast');
                        $("#loadchird").html(msg.d);
                    },
                    error: function (e, i) {
                    alert(JSON.stringify(msg));
                    }
                });

            })

        });

        $(function(){
				$('#myGallery').galleryView();
			});
			
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="contener">
        <div id="wrapper">
            <div id="header">
                <uc1:Header ID="Header1" runat="server" />
            </div>
            <!--End #header-->
            <div id="border">
                <div id="content">
                    <div id="mainNav">
                        <uc2:MainNav ID="MainNav1" runat="server" />
                    </div>
                    <!--End #mainNav-->
                    <div class="itemContent">
                        <div class="gallery">
                            <uc3:SlideOto ID="SlideOto1" runat="server" />
                        </div>
                        <!--End .gallery-->
                    </div>
                    <!--End .itemContent-->
                    <div class="clear">
                    </div>
                    <div id="noidung">
                        <div id="primary-left">
                            <div id="tuvan">
                                <div id="headding">
                                    <%
                                        var artice = artic.GetById(id);
                                        int cateId = artice.CategoryId;
                                        string cateName = cate.GetById(cateId).Name;
                                        string title = artice.Title;
                                        string des = artice.Description;
                                        string conten = HttpUtility.HtmlDecode(artice.Content);
                                        string view = artice.View.ToString();
                                        string date = artice.CreateDate.ToShortDateString();
                                    %>
                                    <ul>
                                        <li>
                                            <%=cateName %></li>
                                    </ul>
                                </div>
                                <!--End #headding-->
                                <div id="detailNews">
                                    <h3>
                                        <%=title %></h3>
                                    <p class="date">
                                        Ngày đăng:
                                        <%=date %></p>
                                    <p class="view">
                                        Lượt xem:
                                        <%=view %></p>
                                        
                                    <h3 style="font-size: 1.2em; color: #2C2C2C; text-align: justify; padding-bottom: 20px;">
                                        <%=des %></h3>
                                    <div style="padding: 0px 10px 15px 10px;">
                                        <%=conten %>
                                        
                                    </div>
                                    <div id="add" style="margin: 10px;">
                                    
                                            <uc8:AddButton ID="AddButton1" runat="server" />
                                    
                                        </div>
                                    <div class="clear"></div>
                                </div>
                                <%
                                    var listOther = artic.GetByCategory(cateId, 5, id);
                                    if (listOther.Count >= 1)
                                    { 
                                %>
                                <div id="otherNews">
                                    <h3>
                                        Bài viết liên quan</h3>
                                    <ul>
                                        <%
                                            foreach (var item in listOther)
                                            {
                                                string titles = item.Title;
                                                string url = "/ArticlesDetails.aspx?Id=" + item.Id.ToString();
                                        %>
                                        <li>+ <a href="<%=url %>">
                                            <%=titles %></a></li>
                                        <%
                                            }
                                        %>
                                    </ul>
                                </div>
                                <%
}
                                %>
                                <%
                                    int galleryId = 0;
                                    if (artice.GalleryParentId != null)
                                        galleryId = Convert.ToInt32(artice.GalleryParentId);
                                    var listImages = gallery.GetByCateGalleryId(galleryId, true);
                                    if (listImages.Count > 0)
                                    { 
                                
                                %>
                                <div id="imagesOther">
                                    <h3>
                                        Hình ảnh</h3>
                                    <div id="listImage">
                                        <%
                                            foreach (var item in listImages)
                                            {
                                                string images1 = item.Image_1;
                                                string images2 = item.Image_2;
                                                string images3 = item.Image_3;
                                                string images4 = item.Image_4;
                                                string images5 = item.Image_5;
                                                string images6 = item.Image_6;
                                                string name = item.Name;
                                        %>
                                            <p>
                                                <a class="group1" href="Images/Gallery/<%=images1 %>" title="<%=name %>">
                                                <img src="Images/Gallery/<%=images1 %>" alt="<%=name %>" /></a>
                                            </p>
                                            <p>
                                                <a class="group1" href="Images/Gallery/<%=images2 %>" title="<%=name %>">
                                                <img src="Images/Gallery/<%=images2 %>" alt="<%=name %>" /></a>
                                            </p>
                                            <p>
                                                <a class="group1" href="Images/Gallery/<%=images3 %>" title="<%=name %>">
                                                <img src="Images/Gallery/<%=images3 %>" alt="<%=name %>" /></a>
                                            </p>
                                            <p>
                                                <a class="group1" href="Images/Gallery/<%=images4 %>" title="<%=name %>">
                                                <img src="Images/Gallery/<%=images4 %>" alt="<%=name %>" /></a>
                                            </p>
                                            <p>
                                                <a class="group1" href="Images/Gallery/<%=images5 %>" title="<%=name %>">
                                                <img src="Images/Gallery/<%=images5 %>" alt="<%=name %>" /></a>
                                            </p>
                                            <p>
                                                <a class="group1" href="Images/Gallery/<%=images6 %>" title="<%=name %>">
                                                <img src="Images/Gallery/<%=images6 %>" alt="<%=name %>" /></a>
                                            </p>

                                        <%
                                            }
                                        %>
                                    </div>
                                    <!--End #image-->
                                </div>
                                <div class="clear">
                                </div>
                                <%
}				    
                                %>
                                <%
			
                                    int videoId = 0;
                                    if (artice.VideoId != null)
                                        videoId = Convert.ToInt32(artice.VideoId);
                                    var videodetail = video.GetById(videoId);
                                    if (videodetail != null)
                                    { 
                                %>
                                <div id="VideoOther">
                                    <h3>
                                        Video</h3>
                                    <%
string videoCode = videodetail.Link;
string html = Myfunction.embedYoutubeID(videoCode, 420, 350);
                                    %>
                                    <p class="video">
                                        <%=html %></p>
                                    <%
                                    %>
                                </div>
                                <%
}				    
                                %>
                            </div>
                            <!--End #tuvan-->
                            <div id="right">
                                <uc4:LeftBar ID="LeftBar1" runat="server" />
                            </div>
                            <!--End #right-->
                        </div>
                        <!--End #primary-->
                        <div id="primary-right">
                            <uc5:RightBar ID="RightBar1" runat="server" />
                        </div>
                        <!--End #primary-right-->
                    </div>
                </div>
                <!--End #content-->
            </div>
            <!--End #border-->
            <div class="clear">
            </div>
            <div id="footer">
                <uc6:Footer ID="Footer1" runat="server" />
            </div>
            <!--End #footer-->
        </div>
        <!--End #wrapper-->
    </div>
    </form>
</body>
</html>
